package com.mappn.backup.util;

import java.util.ArrayList;
import java.util.Scanner;

class WatchThread extends Thread {
	Process p;
	boolean over;
	String stream;

	public WatchThread(Process p) {
		this.p = p;
		over = false;
		stream = new String();
	}

	public void run() {
		try {
			if (p == null)
				return;
			Scanner br = new Scanner(p.getInputStream());
			while (true) {
				if (p == null || over)
					break;
				while (br.hasNextLine()) {
					String tempStream = br.nextLine();
					if (tempStream.trim() == null
							|| tempStream.trim().equals(""))
						continue;
					stream = tempStream;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void setOver(boolean over) {
		this.over = over;
	}

	public String getStream() {
		return stream;
	}
}
